﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;

namespace ConfOrder
{
    public partial class Splash : SplashScreen
    {
        private bool drag = false;
        private Point start_point = new Point(0, 0);
        private bool draggable = true;        

        public Splash()
        {
            this.Cursor = System.Windows.Forms.Cursors.SizeAll;

            this.ShowInTaskbar = true;
            InitializeComponent();

            this.MouseDown += Splash_MouseDown;
            this.MouseUp += Splash_MouseUp;
            this.MouseMove += Splash_MouseMove;
            
        }

        public bool Draggable
        {
            set
            {
                this.draggable = value;
            }
            get
            {
                return this.draggable;
            }
        }

        void Splash_MouseMove(object sender, MouseEventArgs e)
        {
            if (this.drag)
            {
                Point p1 = new Point(e.X, e.Y);
                Point p2 = this.PointToScreen(p1);
                Point p3 = new Point(p2.X - this.start_point.X,
                                     p2.Y - this.start_point.Y);
                this.Location = p3;
            }
        }

        void Splash_MouseUp(object sender, MouseEventArgs e)
        {
            this.drag = false;
        }

        void Splash_MouseDown(object sender, MouseEventArgs e)
        {
            this.drag = true;
            this.start_point = new Point(e.X, e.Y);
        }

        #region Overrides

        public override void ProcessCommand(Enum cmd, object arg)
        {
            base.ProcessCommand(cmd, arg);
        }

        #endregion

        public enum SplashScreenCommand
        {
        }
    }
}